home *** CD-ROM | disk | FTP | other *** search
/ Varios Español / Varios Español.iso / DBASE5 / TEMPLATE.ZIP / AS_UDF.COD < prev    next >
Text File  |  1994-10-12  |  5KB  |  221 lines

  1. //
  2. // Module name: AS_UDF.COD
  3. // Description: Apgen User defined functions
  4. //
  5. {
  6. include "cm_udf.cod"  // Template language UDFs
  7.  
  8.   define dbfOpen(mdbf,mndx,mord,actflag)
  9.   var tempext, // temporary extension
  10.       filestr  // file string
  11. ;
  12.  tempext="";
  13.  filestr="";
  14. //
  15.  if mdbf and (filetype(mdbf) == "DBF" || !filetype(mdbf)) then
  16.    tempext=".DBF";
  17.  else
  18.    if mdbf then
  19.      tempext="."+filetype(mdbf);
  20.    endif
  21.  endif
  22. //
  23.  filestr="Error al abrir ";
  24.  if mdbf then
  25.    filestr=filestr+fileroot(mdbf)+tempext;
  26.  endif
  27.  if mndx then
  28.    if mdbf then
  29.      filestr=filestr+" o ";
  30.    endif
  31.    filestr=filestr+"index(es) "+upper(mndx);
  32.  endif}
  33. lc_message="0"
  34. ON ERROR lc_message=LTRIM(STR(ERROR()))+" "+MESSAGE()
  35. {if tempext == ".VUE" || tempext == ".QBE" || tempext == ".QBO" then}
  36. SET VIEW TO {mdbf}
  37. {else}
  38. {  if tempext == ".UPD" then}
  39. DO {mdbf}
  40. {  else}
  41. USE {mdbf}
  42. {  endif}
  43. {endif}
  44. {if mndx then}
  45. IF "" <> DBF()
  46.   SET INDEX TO {mndx}
  47. ENDIF
  48. {endif}
  49. {if mord then}
  50. SET ORDER TO {mord}
  51. {endif}
  52. ON ERROR
  53. gn_error=VAL(lc_message)
  54. IF gn_error > 0
  55.   DO Pause WITH "{filestr}"
  56. {case actflag of}
  57. {0:}
  58.   gn_error=0
  59.   lc_file="SET"+gc_prognum
  60.   DO &lc_file.
  61.   RETURN
  62. {1:}
  63.   lc_new='S'
  64.   RETURN
  65. {endcase}
  66. ENDIF
  67. lc_new='S'
  68. {return;
  69.  enddef;
  70. }
  71. //
  72. // UDF to handle item level help.
  73. //
  74. {define itmhlp();}
  75. {var hlprcnt;}
  76. {hlprcnt=1;  // line counter}
  77. {foreach Item_Help m in k}
  78. {  if ALLTRIM(Item_Help) then}
  79.     @ {hlprcnt+1},1 SAY "{Item_Help}"
  80. {  endif}
  81. {  ++hlprcnt;}
  82. {  if hlprcnt > 19 then}
  83. {    hlprcnt=1;}
  84. {  endif}
  85. {next m;}
  86. {return hlprcnt;}
  87. {enddef;}
  88. //
  89. // UDF to handle Text in Before and After code embeds and Menu help.
  90. //
  91. {define help_proc();}
  92. {var hlprcnt;}
  93. {hlprcnt=0;  // line counter}
  94. {foreach Menu_Help}
  95. {  if not hlprcnt then hlprcnt=1 endif;}
  96. {  if ALLTRIM(Menu_Help) then}
  97.     @ {hlprcnt+1},1 SAY "{Menu_Help}"
  98. {  endif}
  99. {  ++hlprcnt;}
  100. {  if hlprcnt > 19 then}
  101. {    hlprcnt=1;}
  102. {  endif}
  103. {next k;}
  104. {menucnt=hlprcnt;}
  105. {return;}
  106. {enddef;}
  107. //
  108. {
  109.  define color(getcolor);
  110.  var blink, forground, background, enhanced, incolor;
  111. //
  112.  forground = background = enhanced = 0;
  113. //
  114.  if getcolor != 255 then                      // black on black?
  115.    blink = getcolor >> 7;                     // high order bit set?
  116.    if blink then
  117.      getcolor = getcolor - 128;               // set high order bit to zero
  118.    endif
  119.    background = getcolor >> 4;                // getcolor divided by 16
  120.    forground  = getcolor - (background << 4); // (background times 16)
  121.    if forground > 7 then                      // high intensity?
  122.      enhanced = 1;
  123.      forground = forground - 8;
  124.    endif
  125.  endif
  126.  case forground of
  127.  0: incolor = "N";
  128.  1: incolor = "B";
  129.  2: incolor = "G";
  130.  3: incolor = "GB";
  131.  4: incolor = "R";
  132.  5: incolor = "RB";
  133.  6: incolor = "RG";
  134.  7: incolor = "W";
  135.  endcase
  136.  if blink then incolor = incolor + "*"; endif
  137.  if enhanced then
  138.    incolor = incolor + "+/";
  139.  else
  140.    incolor = incolor + "/";
  141.  endif
  142.  case background of
  143.  0: incolor = incolor + "N";
  144.  1: incolor = incolor + "B";
  145.  2: incolor = incolor + "G";
  146.  3: incolor = incolor + "GB";
  147.  4: incolor = incolor + "R";
  148.  5: incolor = incolor + "RB";
  149.  6: incolor = incolor + "RG";
  150.  7: incolor = incolor + "W";
  151.  endcase
  152.  return incolor;
  153. enddef;
  154. }
  155. {define itemover(cursor);
  156. //
  157. // these routines set a flag variable to indicate whether
  158. // an item in the menu has an overide to the menu database.
  159. // ---------------------------------------------------------
  160. // item database/view
  161. //
  162.     if (not itemview) then
  163.        if cursor.Item_View and (cursor.Item_View != Menu_View) then
  164.          itemview=1;
  165.        endif
  166.      endif
  167. //
  168. // item index
  169. //
  170.     if (not itemndx) then
  171.        if cursor.Item_NDX and (cursor.Item_NDX != Menu_NDX) then
  172.          itemndx=1;
  173.        endif
  174.      endif
  175. //
  176. // item index order
  177. //
  178.     if (not itemord) then
  179.        if cursor.Item_Order and (cursor.Item_Order != Menu_Order) then
  180.          itemord=1;
  181.        endif
  182.      endif
  183. // ---------------------------------------------------------
  184. //
  185.  return;
  186. enddef
  187.  
  188.  
  189. define do_as_headr(cursor)
  190. }
  191. * Autor........: {if author then}{alltrim(author)}{endif}
  192. * Fecha........: {ltrim(SUBSTR(DATE(),1,8))}
  193. * Aviso........: {if Copyright then}{alltrim(Copyright)}{endif}
  194. * Generado por.: dBASE {db_version_no}
  195. { if cursor.Menu_Desc then}
  196. * Descripción..: {alltrim(cursor.Menu_Desc)}
  197. { endif
  198. return;
  199. enddef
  200.  
  201.  
  202. define out_text_with_deli( cursor )
  203. //-------------------------------------------------------------------
  204. // Output to current file a delimited text string
  205. //-------------------------------------------------------------------
  206.   if at( '"', cursor.TEXT_ITEM ) then     // Check for double quote
  207.     }[{cursor.TEXT_ITEM}]{
  208.   else
  209.     if at( "'", cursor.TEXT_ITEM ) then   // Check for single quote
  210.       }[{cursor.TEXT_ITEM}]{
  211.     else
  212.       }"{cursor.TEXT_ITEM}"{
  213.     endif
  214.   endif
  215. return;
  216. enddef
  217.  
  218. }
  219. // EOP AS_UDF.COD
  220.  
  221.